Skip to content

Conversation

@aadamgough
Copy link
Contributor

Summary

Added better error handling for vault specifically. Google Cloud by default has a limit for token expiration, and they throw invalid_grant after the token expires, and the only workaround to this is disconneting and reconnecting credential, or, as an admin, disabling reauth for Sim.

Also added additional params for dates

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 17, 2026 0:50am

Request Review

@aadamgough aadamgough marked this pull request as ready for review January 9, 2026 04:42
@waleedlatif1
Copy link
Collaborator

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Adds specialized error handling for Google Vault credential expiration issues by creating a dedicated block handler that detects RAPT and invalid_grant errors, providing users with actionable reconnection instructions. Extends Google Vault functionality with date filtering (startTime, endTime) and search terms for both exports and holds, plus shared drive support for DRIVE corpus holds. Removes the unused timeZone parameter from export operations.

Confidence Score: 3/5

  • Generally safe to merge with minor validation concerns
  • The PR improves error handling and adds useful functionality, but has duplicate field IDs in the block configuration that could cause form rendering issues. The query object construction in create_matters_holds.ts should be verified to ensure empty query objects are handled correctly by the Google Vault API. The error handling logic itself is well-implemented with comprehensive pattern matching.
  • apps/sim/blocks/blocks/google_vault.ts needs duplicate field ID resolution; apps/sim/tools/google_vault/create_matters_holds.ts needs API validation for empty query objects

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/executor/handlers/google-vault/google-vault-handler.ts 4/5 Adds specialized handler for Google Vault blocks with enhanced credential error detection and user-friendly error messages
apps/sim/tools/google_vault/create_matters_holds.ts 3/5 Adds query parameters for MAIL/GROUPS date filtering and DRIVE shared drive support; query object construction needs validation
apps/sim/blocks/blocks/google_vault.ts 3/5 Adds extensive UI configuration for date filtering and search terms with wand AI prompts; duplicate field IDs need attention

Sequence Diagram

sequenceDiagram
    participant Client
    participant GoogleVaultHandler
    participant executeTool
    participant GoogleVaultAPI
    
    Client->>GoogleVaultHandler: execute(block, inputs)
    GoogleVaultHandler->>GoogleVaultHandler: Transform inputs & parse JSON
    GoogleVaultHandler->>executeTool: Execute with credentials
    executeTool->>GoogleVaultAPI: API Request
    
    alt Success
        GoogleVaultAPI-->>executeTool: Valid response
        executeTool-->>GoogleVaultHandler: result.success = true
        GoogleVaultHandler-->>Client: Return output
    else Credential Error
        GoogleVaultAPI-->>executeTool: invalid_grant/RAPT error
        executeTool-->>GoogleVaultHandler: result.success = false
        GoogleVaultHandler->>GoogleVaultHandler: isCredentialRefreshError()
        GoogleVaultHandler->>GoogleVaultHandler: enhanceCredentialError()
        GoogleVaultHandler-->>Client: User-friendly error with reconnection guidance
    else Other Error
        GoogleVaultAPI-->>executeTool: Other error
        executeTool-->>GoogleVaultHandler: Throws error
        GoogleVaultHandler->>GoogleVaultHandler: Check if credential error
        GoogleVaultHandler-->>Client: Enhanced or standard error message
    end
Loading

@waleedlatif1
Copy link
Collaborator

@greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 17, 2026

Greptile Summary

This PR improves Google Vault integration by adding comprehensive error handling for authentication issues and new date/search filtering parameters.

Key changes:

  • Added enhanceGoogleVaultError utility that detects RAPT (reauthentication policy) errors and provides actionable guidance for users to resolve token expiration issues
  • Added date filtering (startTime, endTime) and search terms (terms) parameters to exports (all corpus types) and holds (MAIL/GROUPS corpus only)
  • Added includeSharedDrives parameter for DRIVE corpus holds
  • Enhanced all tool files with improved error handling that wraps API errors with the new utility
  • Updated UI blocks with separate field names for holds (holdStartTime, holdEndTime, holdTerms) that map to tool parameters, avoiding field ID conflicts
  • Consolidated type definitions and improved parameter descriptions across all tools
  • Updated documentation to reflect new parameters and clarified outputs

Implementation notes:

  • The block configuration correctly uses separate field IDs for export vs hold date/term fields to avoid UI conflicts
  • The params function in google_vault.ts:440-450 properly maps hold-specific fields to their corresponding tool parameter names
  • Error handling enhancement addresses the Google Cloud token expiration issue mentioned in the PR description

Confidence Score: 5/5

  • This PR is safe to merge with well-implemented features and proper error handling
  • The changes are clean, well-structured, and address real user pain points. The error handling enhancement properly detects various authentication failure patterns and provides clear remediation steps. The new date/search parameters are correctly implemented with proper corpus-specific constraints (e.g., date filtering for holds only works with MAIL/GROUPS). The UI configuration cleverly avoids duplicate field IDs by using separate names that are mapped in the params function. Type safety is maintained throughout with proper TypeScript interfaces.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/tools/google_vault/utils.ts Added new utility function for enhancing Google Vault error messages with user-friendly authentication guidance
apps/sim/tools/google_vault/create_matters_export.ts Added date filtering (startTime, endTime) and search terms parameters with enhanced error handling
apps/sim/tools/google_vault/create_matters_holds.ts Added date filtering, search terms for MAIL/GROUPS, includeSharedDrives for DRIVE with enhanced error handling
apps/sim/blocks/blocks/google_vault.ts Added extensive UI fields for date filtering and search terms with wand AI assistance; holds use separate field names mapped to tool parameters

Sequence Diagram

sequenceDiagram
    participant User
    participant Block as Google Vault Block
    participant Tool as Tool Config
    participant API as Google Vault API
    participant Utils as Error Utils
    
    User->>Block: Create export/hold with date filters
    Block->>Block: Map UI fields (holdStartTime → startTime)
    Block->>Tool: Execute with mapped parameters
    Tool->>Tool: Build request body with query filters
    Tool->>API: POST /matters/{matterId}/exports or /holds
    
    alt Success
        API-->>Tool: 200 OK with export/hold data
        Tool-->>Block: Return success output
        Block-->>User: Display result
    else Authentication Error (RAPT/invalid_grant)
        API-->>Tool: 401/403 with error message
        Tool->>Utils: enhanceGoogleVaultError(errorMessage)
        Utils->>Utils: Detect RAPT/token refresh patterns
        Utils-->>Tool: Enhanced error with remediation steps
        Tool-->>Block: Throw enhanced error
        Block-->>User: Show actionable error message
    else Other API Error
        API-->>Tool: Error response
        Tool->>Utils: enhanceGoogleVaultError(errorMessage)
        Utils-->>Tool: Return original message
        Tool-->>Block: Throw error
        Block-->>User: Show error message
    end
Loading

@waleedlatif1 waleedlatif1 merged commit a8d8109 into staging Jan 17, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/google-vault branch January 17, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants